export default {
	_toast(param, fn) {
        uni.showToast({
            ...param
        })
        setTimeout(() => {
            typeof fn === 'function' && fn()
        }, parseInt((param.duration || 1500) * 0.9))
    },
    toast(title, fn) {
        this._toast({
            title,
            duration: 2000,
            icon: 'none'
        }, fn)
    },
    successToast(title, fn) {
        this._toast({
            title,
            duration: 2000,
            icon: 'success'
        }, fn)
    },
       loadingToast(title) {
           this._toast({
               title,
               duration: 2000,
               icon: 'loading'
           })
       },
       showLoading(title= '加载中...') {
           uni.showLoading({
               title,
               mask: true
           })
       },
       hideLoading(){
           uni.hideLoading()
       },
	debugFn(devFn, fn) {
        if (process.env.NODE_ENV === 'development') {
            typeof devFn === 'function' && devFn()
        }else {
            typeof fn === 'function' && fn()
        }
    },
    // 获取当前页面信息
    getCurrentPage() {
        const c = getCurrentPages()
        return c[c.length - 1]
    },
}
